package com.zhuhjay.common.web.annotation;

import com.zhuhjay.common.web.enums.MatchingMode;
import com.zhuhjay.common.web.support.validation.MatchingValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * 自定义 Validation
 * @author ZhuHJay
 * @date 2023/2/25 13:29
 */
@Target({FIELD, PARAMETER})
@Retention(RUNTIME)
@Documented
@Constraint(validatedBy = MatchingValidator.class)
public @interface Matching {
    /** 使用自定义的正则表达式信息 **/
    MatchingMode value();
    String message() default "error";
    Class<?>[] groups() default { };
    Class<? extends Payload>[] payload() default { };
}
